package com.tyust.entity;

import java.util.HashMap;
import java.util.Map;

public class ResponseDto extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;

	public ResponseDto() {
		put("code", Integer.valueOf(0));
		put("msg", "success");
	}

	public static ResponseDto error() {
		return error(500, "未知异常，请联系管理员");
	}

	public static ResponseDto error(String msg) {
		return error(500, msg);
	}

	public static ResponseDto error(int code, String msg) {
		ResponseDto r = new ResponseDto();
		r.put("code", Integer.valueOf(code));
		r.put("msg", msg);
		return r;
	}

	public static ResponseDto ok(String msg) {
		ResponseDto r = new ResponseDto();
		r.put("msg", msg);
		return r;
	}

	public static ResponseDto ok(Map<String, Object> map) {
		ResponseDto r = new ResponseDto();
		r.putAll(map);
		return r;
	}

	public static ResponseDto ok() {
		return new ResponseDto();
	}

	public ResponseDto put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}
